class Solution3 {
    public int removeDuplicates(int[] nums) {
        int count = 0;
        int k = 0;
        for (int i = 1; i < nums.length; i++) {
            if (nums[k] != nums[i]) {
                nums[++k] = nums[i];
                count++;
            }
        }
        return count;
    }
}